/**
 * 验证邮箱格式
 */
export function isValidEmail(email: string): boolean {
  if (!email || email.trim().length === 0) {
    return false;
  }

  // Check for basic structure and forbidden patterns
  if (email.includes('..') || email.includes(' ') || !email.includes('@')) {
    return false;
  }

  // Split and validate parts
  const parts = email.split('@');
  if (parts.length !== 2) {
    return false;
  }

  const [localPart, domainPart] = parts;
  if (!localPart || !domainPart) {
    return false;
  }

  // Domain must have at least one dot
  if (!domainPart.includes('.')) {
    return false;
  }

  // Basic email regex for final validation
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return emailRegex.test(email);
}
